import FormBuilder from '@/components/FormBuilder.vue'

export const useFormBuilder = (props: any) => {
  const formBuilderRef = ref()

  // 动态表单组件
  const Components = (_: any, { slots }: any) => {
    return h(FormBuilder, { ...reactive(props), ref: formBuilderRef }, slots)
  }

  return {
    FormBuilders: Components,
    validate() {
      return formBuilderRef.value.validate()
    },
  }
}
